package io.renren.controller;

import com.alibaba.fastjson.JSONObject;
import io.renren.config.DynamicDataSource;
import io.renren.entity.ModelConfigEntity;
import io.renren.utils.GenUtils;
import io.renren.vo.DataSourceVo;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;
@CrossOrigin
@RestController
@RequestMapping("/config")
public class ConfigController {



    @PostMapping("/updateOrAdd")
    public String updateOrAdd(@RequestBody ModelConfigEntity modelConfigEntity) throws SQLException, NoSuchFieldException, IllegalAccessException {
        GenUtils.setConfig("package",modelConfigEntity.getPack());
        GenUtils.setConfig("moduleName",modelConfigEntity.getModuleName());
        GenUtils.setConfig("author",modelConfigEntity.getAuthor());
        GenUtils.setConfig("email",modelConfigEntity.getEmail());
        GenUtils.setConfig("mainPath",modelConfigEntity.getMainPath());


        return "修改成功:"+ JSONObject.toJSONString(GenUtils.getConfigMap());
    }
}
